/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/16
\**********************/
#include "LuaSlider.h"

#define CObjPtr ((CSliderUI*)m_cobj)

namespace DuiLib {

void LuaSlider::SetEnabled(bool bEnable)
{
    CObjPtr->SetEnabled(bEnable);
}

int LuaSlider::GetChangeStep()
{
    return CObjPtr->GetChangeStep();
}

void LuaSlider::SetChangeStep(int step)
{
    CObjPtr->SetChangeStep(step);
}

int LuaSlider::SetThumbSize(LuaState *L)
{
    LuaStack args(L);
    SIZE sz = LuaHelperNS::GetSize(args[2]);
    CObjPtr->SetThumbSize(sz);
    return 0;
}

int LuaSlider::GetThumbRect(LuaState *L)
{
    RECT rc = CObjPtr->GetThumbRect();
    LuaHelperNS::PushRect(L, rc);
    return 1;
}

int LuaSlider::GetThumbImage(LuaState *L)
{
    SDTString str = CObjPtr->GetThumbImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaSlider::SetThumbImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetThumbImage(str.c_str());
    return 0;
}

int LuaSlider::GetThumbHotImage(LuaState *L)
{
    SDTString str = CObjPtr->GetThumbHotImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaSlider::SetThumbHotImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetThumbHotImage(str.c_str());
    return 0;
}

int LuaSlider::GetThumbPushedImage(LuaState *L)
{
    SDTString str = CObjPtr->GetThumbPushedImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaSlider::SetThumbPushedImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetThumbPushedImage(str.c_str());
    return 0;
}

void LuaSlider::SetValue(int nValue)
{
    CObjPtr->SetValue(nValue);
}

void LuaSlider::SetCanSendMove(bool bCanSend)
{
    CObjPtr->SetCanSendMove(bCanSend);
}

bool LuaSlider::GetCanSendMove()
{
    return CObjPtr->GetCanSendMove();
}

SDLUA_BEGIN_REGISTER(LuaSlider, Slider, Progress)
    SDLUA_REGISTER_FUN_CPP(LuaSlider, SetEnabled, SetEnabled)
    SDLUA_REGISTER_FUN_CPP(LuaSlider, GetChangeStep, GetChangeStep)
    SDLUA_REGISTER_FUN_CPP(LuaSlider, SetChangeStep, SetChangeStep)

    SDLUA_REGISTER_FUN_LUA(LuaSlider, SetThumbSize, SetThumbSize)
    SDLUA_REGISTER_FUN_LUA(LuaSlider, GetThumbRect, GetThumbRect)

    SDLUA_REGISTER_FUN_LUA(LuaSlider, GetThumbImage, GetThumbImage)
    SDLUA_REGISTER_FUN_LUA(LuaSlider, SetThumbImage, SetThumbImage)
    SDLUA_REGISTER_FUN_LUA(LuaSlider, GetThumbHotImage, GetThumbHotImage)
    SDLUA_REGISTER_FUN_LUA(LuaSlider, SetThumbHotImage, SetThumbHotImage)
    SDLUA_REGISTER_FUN_LUA(LuaSlider, GetThumbPushedImage, GetThumbPushedImage)
    SDLUA_REGISTER_FUN_LUA(LuaSlider, SetThumbPushedImage, SetThumbPushedImage)
    
    SDLUA_REGISTER_FUN_CPP(LuaSlider, SetValue, SetValue)
    SDLUA_REGISTER_FUN_CPP(LuaSlider, SetCanSendMove, SetCanSendMove)
    SDLUA_REGISTER_FUN_CPP(LuaSlider, GetCanSendMove, GetCanSendMove)
SDLUA_END_REGISTER

SDLUA_BEGIN_UNREGISTER(LuaSlider, Slider)
SDLUA_END_UNREGISTER(Slider)

}

#undef CObjPtr